/**
 * 
 */
package fr.isima.gui;

import java.text.SimpleDateFormat;
import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import fr.isima.R;
import fr.isima.gui.tag.TrackItem;
import fr.isima.model.Track;

/**
 * @author vincent
 */
public class TrackArrayAdapter extends ArrayAdapter<Track>
{

    /** Debug Tag */
    private static final String TAG = "TrackArrayAdapter";
    

    public TrackArrayAdapter(Context context, int textViewResourceId,
            List<Track> objects)
    {
        super(context, textViewResourceId, objects);
    }

    /* ======================================================= */
    /*
     * @see android.widget.ArrayAdapter#getView(int, android.view.View,
     * android.view.ViewGroup)
     */
    /* ======================================================= */
    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {

        Track track = getItem(position);
        
        return new TrackItem(getContext(), track.getName(),
                new SimpleDateFormat(getContext()
                        .getResources().getString(R.string.dateformat))
                        .format(track.getDate()));
    }

}
